package com.itheima.utils;

import com.itheima.dbservice.SoulScoreServiceApi;
import com.itheima.pojo.SoulScore;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class OptionScoreUtil {
    @DubboReference
    private static SoulScoreServiceApi soulScoreServiceApi;

    /**
     * 获取单个选项分数
     * @param questionId
     * @param optionId
     * @return
     */
    public static Integer getScore(String questionId, String optionId){
        //获取对应id的options分数集合
        SoulScore scorelist = soulScoreServiceApi.getById(questionId);
        //进行选项匹配
        switch (optionId) {
            case "A":
                return scorelist.getA();
            case "B":
                return scorelist.getB();
            case "C":
                return scorelist.getC();
            case "D":
                return scorelist.getD();
            case "E":
                return scorelist.getE();
            case "F":
                return scorelist.getF();
            case "G":
                return scorelist.getG();
            default:
                return 0;
        }
    }

    public static Integer getMsgId(Integer score){
        if (score < 21) {
            return 1;
        }
        if (score < 40) {
            return 2;
        }
        if (score >= 41 && score < 55) {
            return 3;
        }
        if (score >= 56) {
            return 4;
        }
        return 0;
    }

    public static List<Map<String, String>> getDimensionsList(){
        List<Map<String, String>> list = new ArrayList<>();
        {Map<String, String> map = new HashMap<>();
            map.put("key", "外向");
            map.put("value", "48%");
            list.add(map);}
        {Map<String, String> map = new HashMap<>();
            map.put("key", "判断");
            map.put("value", "85%");
            list.add(map);}
        {Map<String, String> map = new HashMap<>();
            map.put("key", "抽象");
            map.put("value", "26%");
            list.add(map);}
        {Map<String, String> map = new HashMap<>();
            map.put("key", "理性");
            map.put("value", "73%");
            list.add(map);}
        return list;
    }
}
